package com.hiultra.archive.controller;

import com.hiultra.archive.domain.ArcEnvironmentSet;
import com.hiultra.archive.service.IArcEnvironmentSetService;
import com.hiultra.common.annotation.Log;
import com.hiultra.common.core.controller.BaseController;
import com.hiultra.common.core.domain.AjaxResult;
import com.hiultra.common.core.page.TableDataInfo;
import com.hiultra.common.enums.BusinessType;
import com.hiultra.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 阈值设置Controller
 * 
 * @author ls
 * @date 2022-07-28
 */
@RestController
@RequestMapping("/environment/set")
@Api(tags="阈值设置Controller")
public class ArcEnvironmentSetController extends BaseController
{
    @Autowired
    private IArcEnvironmentSetService arcEnvironmentSetService;

    /**
     * 查询阈值设置列表
     */
    @ApiOperation(value = "查询阈值设置列表", notes = "查询阈值设置列表")
    @PreAuthorize("@ss.hasPermi('environment:set:list')")
    @GetMapping("/list")
    public TableDataInfo list(ArcEnvironmentSet arcEnvironmentSet)
    {
        startPage();
        List<ArcEnvironmentSet> list = arcEnvironmentSetService.selectArcEnvironmentSetList(arcEnvironmentSet);
        return getDataTable(list);
    }

    /**
     * 导出阈值设置列表
     */
    @ApiOperation(value = "导出阈值设置列表", notes = "导出阈值设置列表")
    @PreAuthorize("@ss.hasPermi('environment:set:export')")
    @Log(title = "阈值设置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ArcEnvironmentSet arcEnvironmentSet)
    {
        List<ArcEnvironmentSet> list = arcEnvironmentSetService.selectArcEnvironmentSetList(arcEnvironmentSet);
        ExcelUtil<ArcEnvironmentSet> util = new ExcelUtil<ArcEnvironmentSet>(ArcEnvironmentSet.class);
        util.exportExcel(response, list, "阈值设置数据");
    }

    /**
     * 获取阈值设置详细信息
     */
    @ApiOperation(value = "获取阈值设置详细信息", notes = "获取阈值设置详细信息")
    @PreAuthorize("@ss.hasPermi('environment:set:query')")
    @GetMapping(value = "/{setId}")
    public AjaxResult getInfo(@PathVariable("setId") Long setId)
    {
        return AjaxResult.success(arcEnvironmentSetService.selectArcEnvironmentSetBySetId(setId));
    }

    /**
     * 新增阈值设置
     */
    @ApiOperation(value = "新增阈值设置", notes = "新增阈值设置")
    @PreAuthorize("@ss.hasPermi('environment:set:add')")
    @Log(title = "阈值设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ArcEnvironmentSet arcEnvironmentSet)
    {
        return toAjax(arcEnvironmentSetService.insertArcEnvironmentSet(arcEnvironmentSet));
    }

    /**
     * 修改阈值设置
     */
    @ApiOperation(value = "修改阈值设置", notes = "修改阈值设置")
    @PreAuthorize("@ss.hasPermi('environment:set:edit')")
    @Log(title = "阈值设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ArcEnvironmentSet arcEnvironmentSet)
    {
        return toAjax(arcEnvironmentSetService.updateArcEnvironmentSet(arcEnvironmentSet));
    }

    /**
     * 删除阈值设置
     */
    @ApiOperation(value = "删除阈值设置", notes = "删除阈值设置")
    @PreAuthorize("@ss.hasPermi('environment:set:remove')")
    @Log(title = "阈值设置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{setIds}")
    public AjaxResult remove(@PathVariable Long[] setIds)
    {
        return toAjax(arcEnvironmentSetService.deleteArcEnvironmentSetBySetIds(setIds));
    }
}
